tests: Handle EPIPE failures when head terminates
authorAlex Kiernan <alex.kiernan@gmail.com>
Thu, 31 Oct 2019 11:30:00 +0000 (11:30 +0000)
committerAlex Kiernan <alex.kiernan@gmail.com>
Fri, 1 Nov 2019 05:05:53 +0000 (05:05 +0000)
When using musl, it appears that the default is line buffered output, so
when `head -1` reads from a pipe we have to handle the source end of the
pipe getting EPIPE.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
tests/pull-test.sh
tests/test-pull-mirrorlist.sh

index 0a97a11955826707d49ae185a6fbc613f5a2627c..2cfd8e02f790ffbba739f3ec4845d17da490d8c9 100644 (file)
@@ -177,7 +177,7 @@ if ! skip_one_without_user_xattrs; then
     ${CMD_PREFIX} ostree --repo=cacherepo pull-local ostree-srv/gnomerepo main
     rev=$(ostree --repo=cacherepo rev-parse main)
     ${CMD_PREFIX} ostree --repo=cacherepo ls -R -C main > ls.txt
-    regfile_hash=$(grep -E -e '^-0' ls.txt | head -1 | awk '{ print $5 }')
+    regfile_hash=$((grep -E -e '^-0' ls.txt || true) | head -1 | awk '{ print $5 }')
     ${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false corruptrepo $(cat httpd-address)/ostree/corruptrepo
     # Make this a loop so in the future we can add more object types like commit etc.
     for object in ${regfile_hash}.file; do
index 4e44852d39711a90b1ef948c1b27f202505770d9..85ff66e99f8ef8f0df0971599d70d0814388e5df 100755 (executable)
@@ -47,12 +47,12 @@ setup_mirror content_mirror3
 
 # Let's delete a file from 1 so that it falls back on 2
 cd ${test_tmpdir}/content_mirror1/ostree/gnomerepo
-filez=$(find objects/ -name '*.filez' | head -n 1)
+filez=$((find objects/ -name '*.filez' || true) | head -n 1)
 rm ${filez}
 
 # Let's delete a file from 1 and 2 so that it falls back on 3
 cd ${test_tmpdir}/content_mirror1/ostree/gnomerepo
-filez=$(find objects/ -name '*.filez' | head -n 1)
+filez=$((find objects/ -name '*.filez' || true) | head -n 1)
 rm ${filez}
 cd ${test_tmpdir}/content_mirror2/ostree/gnomerepo
 rm ${filez}